package com.scy.hospitalmanager.until;

import org.springframework.util.DigestUtils;

/**
 * @Description:
 * @ClassName: MD5
 * @Author: KuonnjiArisu
 * @Date: 2021/8/24 13:29
 * @Version: 1.0
 */
public class MD5 {
    public static String md5(String text) {
        String encodeStr = DigestUtils.md5DigestAsHex(text.getBytes());
        return encodeStr;
    }

    public static boolean verify(String text, String md5) {
        String md5Text = md5(text);
        if (md5Text.equalsIgnoreCase(md5)) {
            return true;
        }
        return false;
    }
    public static String deciphering(String md5){
        char[] a = md5.toCharArray();
        for(int i=0;i<a.length;i++){
                a[i] = (char)(a[i]^'t');
        }
        String passwd = new String(a);
        return passwd;
    }
}
